package de.jmda.mproc.swingui;

import java.io.File;
import java.io.FileFilter;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import de.jmda.mproc.swingui.AnnotationProcessorDictionary;

public class JUTAnnotationProcessorDictionary
{
	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception
	{
	}

	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public final void testGetAnnotationProcessorClassnames()
	{
		List<String> annotationProcessorClassnames;
		
		long start = System.currentTimeMillis();
		
		// just create the dictionary and see if search is started in background
    AnnotationProcessorDictionary annotationProcessorDictionary =
    		new AnnotationProcessorDictionary(
//    				ClasspathUtil.NONE_REJECTING_FILE_FILTER);
    				new FileFilter()
						{
							@Override
							public boolean accept(File pathname)
							{
								return pathname.getName().endsWith(".jar") == false;
							}
						}
    		);
		
		long stop = System.currentTimeMillis();

		System.out.println(
				"continuing after " + (stop - start) + " milliseconds");

		long startGet = System.currentTimeMillis();
		
		annotationProcessorClassnames =
				annotationProcessorDictionary.getAnnotationProcessorClassnames();
		
		long stopGet = System.currentTimeMillis();
		
		System.out.println(
				"finished search after " + (stopGet - startGet) + " milliseconds");
				
	  for (String annotationProcessorClassname :
	  	   annotationProcessorClassnames)
	  {
	  	System.out.println(annotationProcessorClassname);
	  }
	}
}
